home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / c / bc_pas_1.zip / BLOCKIN.C < prev    next >
C/C++ Source or Header  |  1992-09-24  |  3KB  |  109 lines

  1. /*$Author:   DCODY  $*/
  2. /*$Date:   24 Sep 1992 08:59:06  $*/
  3. /*$Header:   X:/sccs/pcmapps/blockin.c_v   1.5   24 Sep 1992 08:59:06   DCODY  $*/
  4. /*$Log:   X:/sccs/pcmapps/blockin.c_v  $
  5.  * 
  6.  *    Rev 1.5   24 Sep 1992 08:59:06   DCODY
  7.  * changed MVGetHardware to mvGetHardware
  8.  * 
  9.  *    Rev 1.4   28 Jul 1992 15:52:20   DCODY
  10.  * added TurnItOff, TurnItOn to get rid of feedback during recordings.
  11.  * 
  12.  *    Rev 1.3   20 Jul 1992 11:39:06   DCODY
  13.  * call to mvGetHWVersion now uses active I/O address detection.
  14.  * 
  15.  *    Rev 1.2   13 Jul 1992 19:05:04   DCODY
  16.  * removed initmvsound call. changed pcmstate to add 8 bit pcm parm.
  17.  * 
  18.  *    Rev 1.1   23 Jun 1992 16:09:24   DCODY
  19.  * pas2 update...
  20.  * 
  21.  *    Rev 1.0   15 Jun 1992 09:26:24   BCRANE
  22.  * Initial revision.
  23. */
  24. /*$Logfile:   X:/sccs/pcmapps/blockin.c_v  $*/
  25. /*$Modtimes$*/
  26. /*$Revision:   1.5  $*/
  27. /*$Workfile:   blockin.c  $*/
  28.  
  29.  
  30. /* simple PCM data recorder - writes blocks of data to the disk         */
  31.  
  32. #include <stdio.h>
  33. #include <stdlib.h>
  34. #include <malloc.h>
  35. #include <signal.h>
  36. #include "pcmio.h"
  37. #include "common.h"
  38.  
  39. char OurData[4096];
  40.  
  41. main()
  42. {
  43. FILE *f;
  44.  
  45.     /* abort if the hardware is not found                                */
  46.  
  47.         if (mvGetHWVersion(USE_ACTIVE_ADDR) == -1) {
  48.             printf ("\aThe Pro AudioSpectrum hardware is not installed!\n");
  49.             exit(1);
  50.         }
  51.  
  52.     /* open a file                                                        */
  53.  
  54.         f = fopen("xxx.pcm","wb");
  55.  
  56.     /* Turn off the PCM to avoid feedback                                */
  57.  
  58.         TurnItOff();
  59.  
  60.     /* open the PCM code                                                */
  61.  
  62.         if (OpenPCMBuffering(-1,-1,16,4)) {
  63.             printf ("\aCannot setup the PCM software!\n");
  64.             exit(1);
  65.         }
  66.  
  67.     /* setup the sample rate & stereo flag                                */
  68.  
  69.         PCMState (22050L, 0, 0, 8);     /* 22050 khz, mono, 8 bit pcm    */
  70.  
  71.     /* if the DMA engine starts, keep the data moving to disk!            */
  72.  
  73.         if (StartBlockInput()) {
  74.  
  75.             while (1) {
  76.  
  77.                 /* if ESC typed, kill the DMA & exit                    */
  78.  
  79.                     if (kbhit()) {
  80.                         if (getch() == 0x1b) {
  81.                             StopDMAIO();
  82.                             break;
  83.                         }
  84.                     }
  85.  
  86.                 /* if all done, then just break                         */
  87.  
  88.                     if (ContinueBlockInput(OurData)) {
  89.                         if (fwrite (OurData,1,4096,f) != 4096) {
  90.                             StopDMAIO();
  91.                             break;
  92.                         }
  93.                     }
  94.             }
  95.         }
  96.  
  97.     /* exit to DOS                                                        */
  98.  
  99.         ClosePCMBuffering();
  100.         close (f);
  101.  
  102.     /* restore the PCM mixer channel                                    */
  103.  
  104.         TurnItOn();
  105.  
  106.         exit(0);
  107. }
  108.  
  109.